
pkgname=inetutils
pkgver=1.9.4
pkgrel=6
pkgdesc="A collection of common network programs."
arch=('x86_64')
url="https://www.gnu.org/software/inetutils/"
license=('GPL')
depends=('readline' 'ncurses' 'pam')
makedepends=('help2man')
backup=('etc/conf.d/ftpd' 'etc/xinetd.d/telnet' 'etc/xinetd.d/talk')
options=('!emptydirs')
source=("https://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.gz"
        'ftpd.conf' 'telnet.xinetd' 'talk.xinetd' 'rlogin.xinetd'
        'rsh.xinetd' 'ftpd.service')
md5sums=('04852c26c47cc8c6b825f2b74f191f52'
         'e6e6e5990a2e8159a276fef8fbf54c04'
         '8596208d119045543c5fb644e1d713d5'
         '2c3655985cf122591d71d031af84ff90'
         'c25d8382a994de84d9c6962d804f689b'
         'c3aa508a9d1293a787341108cd49c1b7'
         'c04b4f0d41d9b59081f314335f8d9d60')

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr --libexec=/usr/sbin --localstatedir=/var \
    --sysconfdir=/etc --mandir=/usr/share/man --infodir=/usr/share/info \
    --without-wrap --with-pam \
    --enable-ftp --enable-ftpd \
    --enable-telnet --enable-telnetd \
    --enable-talk --enable-talkd \
    --enable-rlogin --enable-rlogind \
    --enable-rsh --enable-rshd \
    --enable-rcp --enable-hostname \
    --disable-rexec --disable-rexecd \
    --disable-tftp --disable-tftpd \
    --disable-ping --disable-ping6 \
    --disable-logger --disable-syslogd \
    --disable-inetd --disable-whois \
    --disable-uucpd \
    --disable-ifconfig --disable-traceroute \
    --enable-dnsdomainname 

  make
}

check() {
  cd ${pkgname}-${pkgver}
  
  make check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install
  
  install -d ${pkgdir}/bin
  ln -s /usr/bin/hostname ${pkgdir}/bin/hostname
  ln -s /usr/bin/dnsdomainname ${pkgdir}/bin/dnsdomainname


  install -D -m644 ${srcdir}/ftpd.service ${pkgdir}/usr/lib/systemd/system/ftpd.service
  install -D -m644 ${srcdir}/ftpd.conf ${pkgdir}/etc/conf.d/ftpd
  install -D -m644 ${srcdir}/telnet.xinetd ${pkgdir}/etc/xinetd.d/telnet
  install -D -m644 ${srcdir}/talk.xinetd ${pkgdir}/etc/xinetd.d/talk
  install -D -m644 ${srcdir}/rlogin.xinetd ${pkgdir}/etc/xinetd.d/rlogin
  install -D -m644 ${srcdir}/rsh.xinetd ${pkgdir}/etc/xinetd.d/rsh
}

